From 9e777a0acbde64bd0630b59d255894b4b7ebaec8 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Thu, 10 Jun 2004 11:44:59 +0000 Subject: [PATCH] bitkeeper revision 1.949 (40c849bbwzGqdgyEGz_X9EcI9GanBw) Plumb bind_virq Xen command thru to Python. --- tools/xc/lib/xc.h | 3 +++ tools/xc/lib/xc_evtchn.c | 22 ++++++++++++++++++++++ tools/xc/py/Xc.c | 26 ++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/tools/xc/lib/xc.h b/tools/xc/lib/xc.h index 86edd09c4f..19cd720265 100644 --- a/tools/xc/lib/xc.h +++ b/tools/xc/lib/xc.h @@ -229,6 +229,9 @@ int xc_evtchn_bind_interdomain(int xc_handle, u32 dom2, /* may be DOMID_SELF */ int *port1, int *port2); +int xc_evtchn_bind_virq(int xc_handle, + int virq, + int *port); int xc_evtchn_close(int xc_handle, u32 dom, /* may be DOMID_SELF */ int port); diff --git a/tools/xc/lib/xc_evtchn.c b/tools/xc/lib/xc_evtchn.c index 22654be515..624f5b1c15 100644 --- a/tools/xc/lib/xc_evtchn.c +++ b/tools/xc/lib/xc_evtchn.c @@ -8,6 +8,7 @@ #include "xc_private.h" + static int do_evtchn_op(int xc_handle, evtchn_op_t *op) { int ret = -1; @@ -29,6 +30,7 @@ static int do_evtchn_op(int xc_handle, evtchn_op_t *op) out1: return ret; } + int xc_evtchn_bind_interdomain(int xc_handle, u32 dom1, u32 dom2, @@ -54,6 +56,26 @@ int xc_evtchn_bind_interdomain(int xc_handle, } +int xc_evtchn_bind_virq(int xc_handle, + int virq, + int *port) +{ + evtchn_op_t op; + int rc; + + op.cmd = EVTCHNOP_bind_virq; + op.u.bind_virq.virq = (u32)virq; + + if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 ) + { + if ( port != NULL ) + *port = op.u.bind_virq.port; + } + + return rc; +} + + int xc_evtchn_close(int xc_handle, u32 dom, int port) diff --git a/tools/xc/py/Xc.c b/tools/xc/py/Xc.c index bac671183d..e1ac79077d 100644 --- a/tools/xc/py/Xc.c +++ b/tools/xc/py/Xc.c @@ -1050,6 +1050,25 @@ static PyObject *pyxc_evtchn_bind_interdomain(PyObject *self, "port2", port2); } +static PyObject *pyxc_evtchn_bind_virq(PyObject *self, + PyObject *args, + PyObject *kwds) +{ + XcObject *xc = (XcObject *)self; + + int virq, port; + + static char *kwd_list[] = { "virq", NULL }; + + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &virq) ) + return NULL; + + if ( xc_evtchn_bind_virq(xc->xc_handle, virq, &port) != 0 ) + return PyErr_SetFromErrno(xc_error); + + return PyInt_FromLong(port); +} + static PyObject *pyxc_evtchn_close(PyObject *self, PyObject *args, PyObject *kwds) @@ -1648,6 +1667,13 @@ static PyMethodDef pyxc_methods[] = { " port1 [int]: Port-id for endpoint at dom1.\n" " port2 [int]: Port-id for endpoint at dom2.\n" }, + { "evtchn_bind_virq", + (PyCFunction)pyxc_evtchn_bind_virq, + METH_VARARGS | METH_KEYWORDS, "\n" + "Bind an event channel to the specified VIRQ.\n" + " virq [int]: VIRQ to bind.\n\n" + "Returns: [int] Bound event-channel port.\n" }, + { "evtchn_close", (PyCFunction)pyxc_evtchn_close, METH_VARARGS | METH_KEYWORDS, "\n" -- 2.30.2